package com.demo.weather.receiver;

import org.springframework.stereotype.Component;

import com.demo.weather.packet.data.FunctionType;
import com.demo.weather.packet.data.PacketData;

import lombok.extern.slf4j.Slf4j;

/**
 * 实时监测业务数据处理
 *
 * @author tangheng
 */
@Component
@Slf4j
public class RealTimeMonitorPacketReceiver implements PacketReceiver {

    @Override
    public void handle(PacketData messagePacket) {
    	byte[] payloadContent = messagePacket.getPayload().getContent();
    	RealTimeMonitorGroup group = RealTimeMonitorGroup.of(payloadContent);
    	// 实时监测数据已完成业务规则解析，可以控制台查看解析后的结果
    	log.debug("实时监测数据已完成业务规则解析，可以控制台查看解析后的结果: {}", group.getRealTimeMonitors().length);
    }

	@Override
	public FunctionType supportedFunctionType() {
		return FunctionType.REAL_TIME_MONITOR;
	}
}